Create New Module

This guide outlines how to add a new module to the project using baselines convention plugins.

1. Choose the Layer

Determine where your module belongs to maintain architectural separation:

LayerPurpose
uiFeature screens, navigation, theming.
domainBusiness logic, use-case orchestration, rules.
dataRepository implementations, network, database.
toolkitReusable utilities, DI, logging, crypto, etc.

Action: Create a directory under the chosen layer (e.g., ui/profile).


2. Configure the Module

Choose the type of module you are building below.

Note: For both options, register the new module in settings.gradle.kts, e.g. include(":ui:profile").

Namespaces are derived from BuildConfig.NAMESPACE in build-logic/convention/src/main/kotlin/io/baselines/gradle/BuildConfig.kt and the module path. For example, a base of com.example and :ui:profile produce com.example.ui.profile.

For modules with unit tests, add alias(libs.plugins.baselines.testing.unit) to the plugins block. It configures test dependencies and Android unit/host tests for either module type.

🅰️ Option A: Multiplatform Module (Android + iOS)

Standard choice for most logic and UI.

1. Create build.gradle.kts Create the file inside your new directory and paste the following content.

kotlin
1plugins {
2 alias(libs.plugins.baselines.multiplatform.library)
3 // Only needed if this module contains UI/Compose code
4 alias(libs.plugins.baselines.compose)
5}
6
7// Define dependencies
8kotlin {
9 sourceSets {
10 commonMain.dependencies {
11 // Shared dependencies
12 }
13 androidMain.dependencies {
14 // Android specific
15 }
16 iosMain.dependencies {
17 // iOS specific
18 }
19 }
20}

2. Create Folder Structure Create the source folders matching your namespace (e.g., com/example/ui/profile):

text
1📂 src
2 ┣ 📂 commonMain/kotlin/com/example/ui/profile
3 ┣ 📂 androidMain/kotlin/com/example/ui/profile
4 ┗ 📂 iosMain/kotlin/com/example/ui/profile

🅱️ Option B: Android-Only Module

Use for platform-specific features (e.g., Google Services, Camera, Splash).

1. Create build.gradle.kts Create the file inside your new directory and paste the following content.

kotlin
1plugins {
2 alias(libs.plugins.baselines.android.library)
3 // Only needed if this module contains UI/Compose code
4 alias(libs.plugins.baselines.compose)
5}
6
7// Define dependencies
8dependencies {
9 // Android dependencies
10}

2. Create Folder Structure Create the standard Android source folder matching your namespace:

text
1📂 src
2 ┗ 📂 main/kotlin/com/example/ui/profile